import 'package:flutter/material.dart';
import 'package:flutter_banner_swiper/flutter_banner_swiper.dart';


// class HomePage extends StatelessWidget {
//   @override
//   Widget build(BuildContext context) {
//     return Container(
      
//     );
//   }
// }


// 首页页面
// class HomePage extends StatelessWidget {
//   const HomePage({Key key}) : super(key: key);

//   @override
//   Widget build(BuildContext context) {
//     return Text('第一个页面');
//   }
// }



class HomePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return _HomePageState();
  }

}
class _HomePageState extends State<HomePage>{
  @override
  void initState() {
    bannerList.add("https://s3.jpg.cm/2020/08/02/bbMRe.jpg");
    bannerList.add("https://s3.jpg.cm/2020/08/02/bbx3k.jpg");
    bannerList.add("https://s3.jpg.cm/2020/08/02/bbaQ8.jpg");
    bannerList.add("https://s3.jpg.cm/2020/08/02/bb99w.jpg");
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return getList();
  }

  List<String> bannerList=new List();
  Widget getList() {
    return BannerSwiper(
      //width  和 height 是图片的高宽比  不用传具体的高宽   必传
      //默认120
      height: 40,
      //默认54
      width: 54,
      //轮播图数目 必传
      length: 4,
      //轮播的item  widget 必传
      getwidget: (index) {
        return new GestureDetector(
            child: Image.network(
              bannerList[index % bannerList.length],
              fit: BoxFit.cover,
            ),
            onTap: () {
              //点击后todo
            });
      },
    );
  }

}